package Z_exchange;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import utils.RabbitMQUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import static Z_exchange.MqConst.EXCHANGE_NAME;

/**
 * @author： pang-yun
 * @date： 2021-12-15 17:48
 * 功能目的 ：用于
 */

public class LogConsumer2 {
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMQUtils.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME, MqConst.TypeMy.FAN_OUT.getValue());

        String queue = channel.queueDeclare().getQueue();
        channel.queueBind(queue,EXCHANGE_NAME,"");

        DeliverCallback callback=(consumerTag, message)->{
            System.out.println(new String(message.getBody()));
        };
        channel.basicConsume(queue,true,callback,a->{});
    }
}
